go to previous page   go to home page   go to next page

Answer:

Yes


Example with #

Here is a fragment, using #

double A= 0.1, B= -0.1;

DecimalFormat numform = new DecimalFormat(" ##0.###;-##0.###"); 

System.out.println( "A = " + numform.format(A) );  
System.out.println( "B = " + numform.format(B) );  

The fragment writes:

A =  0.1
B = -0.1

Format patterns that contain # create strings of varying lengths, so it is hard to align numbers in columns of output.


QUESTION 14:

What does the following fragment write?

double A= 123.1, B= -1.1;

DecimalFormat numform = new DecimalFormat(" ##0.###;-##0.###"); 

System.out.println( "A = " + numform.format(A) ); 
System.out.println( "B = " + numform.format(B) );